<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 skin-theme-clientpref-day vector-sticky-header-enabled" lang="de" dir="ltr"><head>
<meta charset="UTF-8">
<title>Co-array Fortran</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./_res_/favicon.png">
<link rel="canonical" href="https://de.wikipedia.org/wiki/Co-array_Fortran"> <link href="./_mw_/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link href="./_mw_/ext.gadget.citeRef.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.defaultPlainlinks.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.dewikiCommonHide.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.dewikiCommonLayout.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.dewikiCommonStyle.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.dewikiDarkmode.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.dewikiResponsive.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.gadget.specialSearch.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
<link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
<link rel="stylesheet" type="text/css" href="./_res_/footer.css">
<link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Co-array_Fortran rootpage-Co-array_Fortran skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Co-array Fortran</span></h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="contentSub">
<div id="mw-content-subtitle"></div>
</div>
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="de" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="de" dir="ltr"><table class="float-right infobox toccolours toptextcells" style="font-size:90%; margin-top:0; width:21em;">
<tbody><tr>
<th colspan="2" class="hintergrundfarbe6" style="font-size:larger;">Coarray Fortran
</th></tr>
<tr>
<th colspan="2" class="hintergrundfarbe5" style="font-size:105%; text-align:center;">Basisdaten
</th></tr>
<tr>
<td><b><a href="Programmierparadigma" title="Programmierparadigma">Paradigmen</a>:</b>
</td>
<td><a href="Prozedurale_Programmierung" title="Prozedurale Programmierung">prozedural</a>, <a href="Imperative_Programmierung" title="Imperative Programmierung">imperativ</a>, <a href="Strukturierte_Programmierung" title="Strukturierte Programmierung">strukturiert</a>, <a href="Objektorientierte_Programmierung" title="Objektorientierte Programmierung">objektorientiert</a>, <a href="Parallele_Programmierung" title="Parallele Programmierung">parallel</a>
</td></tr>
<tr>
<td><b>Erscheinungsjahr:</b>
</td>
<td><span class="wikidata-content">1990er</span>
</td></tr>
<tr>
<td><b>Entwickler:</b>
</td>
<td>Robert Numrich and John Reid
</td></tr>
<tr>
<td><b>Aktuelle <a href="Version_(Software)" title="Version (Software)">Version</a>:</b>
</td>
<td style="white-space:nowrap;"><a href="Fortran" title="Fortran">Fortran</a> 2008 (ISO/IEC 1539-1:2010) <small>()</small>
</td></tr>
<tr>
<td><b>Wichtige <a href="Implementierung" title="Implementierung">Implementierungen</a>:</b>
</td>
<td>Cray, <a href="G95" class="mw-redirect" title="G95">g95</a>, <a href="Gfortran" class="mw-redirect" title="Gfortran">gfortran</a>, <a href="Intel_Fortran_Compiler" title="Intel Fortran Compiler">ifort</a>
</td></tr>
<tr>
<td><b>Beeinflusst von:</b>
</td>
<td><a href="Fortran" title="Fortran">Fortran</a>
</td></tr>
</tbody></table>
<p><b>Co-array Fortran</b> (CAF), ehemals <b>F--</b>, ist eine Erweiterung der <a href="Programmiersprache" title="Programmiersprache">Programmiersprache</a> <a href="Fortran" title="Fortran">Fortran</a> 95/2003 zur <a href="Parallele_Programmierung" title="Parallele Programmierung">parallelen Datenverarbeitung</a>, die von Robert Numrich und John Reid in den 1990er Jahren entwickelt wurde. Der Fortran-Standard unterstützt Coarrays (jetzt ohne Bindestrich) seit Fortran 2008 (ISO/IEC 1539-1:2010), wie es auf dem May-2005-Treffen des ISO Fortran Komitees beschlossen wurde; die Syntax im Fortran 2008 Standard unterscheidet sich leicht vom ursprünglichen CAF-Vorschlag.
</p><p>Ein Coarray-Fortran-Programm wird so interpretiert, als ob es <i>n</i>-mal <a href="Replikation_(Datenverarbeitung)" title="Replikation (Datenverarbeitung)">repliziert</a> würde und alle Kopien asynchron ausgeführt würden. Jede Kopie hat ihre eigenen Datenobjekte und wird Bild („image“) genannt. Die <a href="Feld_(Datentyp)" class="mw-redirect" title="Feld (Datentyp)">Feld</a>-Syntax von Fortran wird erweitert um rechteckige Klammern, die den Bildindex enthalten, mit dem man so auf die Daten eines anderen Bildes (Prozesses) zugreifen kann.
</p><p>Die Co-array-Fortran-Erweiterung gibt es schon seit den 1990ern und sie wird in einigen Fortrancompilern wie zum Beispiel dem von <a href="Cray" title="Cray">Cray</a> (ab Version 3.1) unterstützt. Seitdem Coarrays Teil von Fortran 2008 sind, nimmt die Anzahl der Implementation zu; der erste <a href="Open_Source" title="Open Source">Open-Source</a>-<a href="Compiler" title="Compiler">Compiler</a>, der Coarrays gemäß dem Fortran-2008-Standard unterstützt, ist <a href="G95" class="mw-redirect" title="G95">G95</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Beispiel">Beispiel</h2></div>
<div class="mw-highlight mw-highlight-lang-fortran mw-content-ltr" dir="ltr"><pre><span></span><span class="k">program </span><span class="n">Hallo_Welt</span>
<span class="w"> </span><span class="k">implicit none</span>
<span class="k"> </span><span class="kt">integer</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="c">! Lokale Variable</span>
<span class="w"> </span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span><span class="w"> </span><span class="kd">::</span><span class="w"> </span><span class="n">name</span><span class="p">[</span><span class="o">*</span><span class="p">]</span><span class="w"> </span><span class="c">! skalares Coarray</span>
<span class="w"> </span><span class="c">! Hinweis: "name" ist die lokale Variable wohingegen "name[<index>]"</span>
<span class="w"> </span><span class="c">! auf die Variable eines anderen Prozesses (Image) zugreift</span>
<span class="w"> </span><span class="c">! Kommuniziere mit dem Nutzer auf Image 1</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nb">this_image</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="k">then</span>
<span class="k"> write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="s1">'(a)'</span><span class="p">,</span><span class="n">advance</span><span class="o">=</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Geben Sie Ihren Namen ein: '</span>
<span class="w"> </span><span class="k">read</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="s1">'(a)'</span><span class="p">)</span><span class="w"> </span><span class="n">name</span>
<span class="w"> </span><span class="c">! Verteile die Information an die anderen Prozesse</span>
<span class="w"> </span><span class="k">do </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="nb">num_images</span><span class="p">()</span>
<span class="w"> </span><span class="n">name</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">name</span>
<span class="w"> </span><span class="k">end do</span>
<span class="k"> end if</span>
<span class="k"> sync all</span><span class="w"> </span><span class="c">! Barriere damit die Daten wirklich da sind</span>
<span class="w"> </span><span class="c">! Ein-/Ausgabe von allen Prozessen</span>
<span class="w"> </span><span class="k">write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="s1">'(3a,i0)'</span><span class="p">)</span><span class="w"> </span><span class="s1">'Hallo '</span><span class="p">,</span><span class="nb">trim</span><span class="p">(</span><span class="n">name</span><span class="p">),</span><span class="s1">' von Image '</span><span class="p">,</span><span class="w"> </span><span class="nb">this_image</span><span class="p">()</span>
<span class="k">end program </span><span class="n">Hallo_Welt</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Siehe_auch">Siehe auch</h2></div>
<ul><li><a href="Unified_Parallel_C" title="Unified Parallel C">Unified Parallel C</a></li>
<li><a href="Parallele_Programmierung" title="Parallele Programmierung">Parallele Programmierung</a></li>
<li><a href="Partitioned_Global_Address_Space" title="Partitioned Global Address Space">Partitioned Global Address Space</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Weblinks">Weblinks</h2></div>
<ul><li><a rel="nofollow" class="external text" href="http://www.nag.co.uk/sc22wg5/">ISO Fortran Committee</a></li>
<li><a rel="nofollow" class="external text" href="ftp://ftp.nag.co.uk/sc22wg5/N1751-N1800/N1787.pdf">Coarrays in the next Fortran Standard</a> (PDF)</li>
<li><a rel="nofollow" class="external text" href="ftp://ftp.nag.co.uk/sc22wg5/N1801-N1850/N1824.pdf">Rationale for Co-Arrays in Fortran 2008</a> (PDF)</li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
Dieser Artikel wurde von <a class="external text" title="Zuletzt bearbeitet am 2024-04-14" href="https://de.wikipedia.org/wiki/?title=Co-array_Fortran&oldid=244040395">Wikipedia</a> herausgegeben. Der Text ist unter <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.de">Creative Commons Attribution-Share Alike 4.0</a> verfügbar, sofern nicht anders angegeben. Für die Mediendateien können zusätzliche Bedingungen gelten.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
<script src="./_webp_/webpHandler.js"></script>
</body></html>